<?php

namespace App\Repositories\Transformers;

use App\Models\MeetDay;
use Carbon\Carbon;
use League\Fractal\TransformerAbstract;

class MeetDayListTransformer extends TransformerAbstract
{
    public function transform(MeetDay $meetDay)
    {
        // 小时
        $hoursArr = [];
        if (!empty($meetDay->hours)) {
            foreach ($meetDay->hours as $item) {
                $temp = [];
                $temp['meet_hour_id'] = (string)$item->meet_hour_id;
                $temp['start'] = $item->start;
                $temp['end'] = $item->end;
                $temp['is_limit'] = $item->is_limit;
                $temp['limit'] = $item->limit;
                $temp['status'] = $item->status;
                array_push($hoursArr, $temp);
            }

        }

        return [
            // 'venue_id' => $meetDay->venue_id,
            'day' => Carbon::parse($meetDay->day)->toDateString(),
            'status' => $meetDay->status,
            'hours' => $hoursArr,

        ];

    }
}
